package com.ruoyi.web.controller.edh;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.edh.domain.EdhScheduled;
import com.ruoyi.edh.service.IEdhScheduledService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 易订货-排期Controller
 *
 * @author xxx
 * @date 2020-09-22
 */
@RestController
@RequestMapping("/edh/scheduled")
@Api(description = "易订货-排期")
public class EdhScheduledController extends BaseController {
    @Autowired
    private IEdhScheduledService edhScheduledService;

    /**
     * 查询易订货-排期列表
     */
    @PreAuthorize("@ss.hasPermi('edh:scheduled:list')")
    @GetMapping("/list")
    @ApiOperation("易订货-排期列表")
    public TableDataInfo list(EdhScheduled edhScheduled) {
        startPage();
        List<EdhScheduled> list = edhScheduledService.selectEdhScheduledList(edhScheduled);
        return getDataTable(list);
    }

    /**
     * 导出易订货-排期列表
     */
    @PreAuthorize("@ss.hasPermi('edh:scheduled:export')")
    @Log(title = "易订货-排期", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出易订货-排期列表")
    public AjaxResult export(EdhScheduled edhScheduled) {
        List<EdhScheduled> list = edhScheduledService.selectEdhScheduledList(edhScheduled);
        ExcelUtil<EdhScheduled> util = new ExcelUtil<EdhScheduled>(EdhScheduled.class);
        return util.exportExcel(list, "scheduled");
    }

    /**
     * 获取易订货-排期详细信息
     */
    @PreAuthorize("@ss.hasPermi('edh:scheduled:query')")
    @GetMapping("/{id}")
    @ApiOperation("获取易订货-排期详细信息")
    public AjaxResult getInfo(@PathVariable Long id) {
        return AjaxResult.success(edhScheduledService.selectEdhScheduledById(id));
    }

    /**
     * 新增易订货-排期
     */
    @PreAuthorize("@ss.hasPermi('edh:scheduled:add')")
    @Log(title = "易订货-排期", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增易订货-排期")
    public AjaxResult add(@RequestBody EdhScheduled edhScheduled) {
        return toAjax(edhScheduledService.insertEdhScheduled(edhScheduled));
    }

    /**
     * 修改易订货-排期
     */
    @PreAuthorize("@ss.hasPermi('edh:scheduled:edit')")
    @Log(title = "易订货-排期", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改易订货-排期")
    public AjaxResult edit(@RequestBody EdhScheduled edhScheduled) {
        return toAjax(edhScheduledService.updateEdhScheduled(edhScheduled));
    }

    /**
     * 删除易订货-排期
     */
    @PreAuthorize("@ss.hasPermi('edh:scheduled:remove')")
    @Log(title = "易订货-排期", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除易订货-排期")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(edhScheduledService.deleteEdhScheduledByIds(ids));
    }

    /**
     * 排期商品管理
     */
    @Log(title = "排期商品管理", businessType = BusinessType.DELETE)
    @GetMapping("/editscheduledgoods")
    @ApiOperation("排期商品管理")
    public AjaxResult editscheduledgoods(Long id, Long[] goodsId) {
        return toAjax(edhScheduledService.editscheduledgoods(id, goodsId));
    }

}
